package com.cby.jetpack.sample.binding

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.cby.jetpack.sample.R
import com.cby.jetpack.sample.binding.data.User2
import com.cby.jetpack.sample.databinding.ActivityDataBindTest2Binding

/**
 * @description: TestDataBindingActivity
 *
 * @author ChenBaoyang
 * @date 8/9/21 14:47
 */
class TestDataBinding2Activity : AppCompatActivity() {

    private lateinit var binding: ActivityDataBindTest2Binding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView(this@TestDataBinding2Activity, R.layout.activity_data_bind_test2)
        val user = User2()
        user.userName.set("jason")
        user.userGender.set("boy")
        user.userId.set(123123)
        binding.user = user

        binding.btnReset.setOnClickListener {
            user.userGender.set("girl")
            user.userName.set("kevin")
            user.userId.set(444448888)
        }
    }
}